package com.example.demo.controller;

import com.example.demo.pojo.Result;
import com.example.demo.pojo.entity.TreeHoles;
import com.example.demo.pojo.entity.TreeHolesComment;
import com.example.demo.service.TreeHolesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/polycystic/treeHoles")
public class TreeHolesController {

    @Autowired
    private TreeHolesService treeHolesService;

    @GetMapping("/list")
    public Result<List<TreeHoles>> list(String content){
        List<TreeHoles> list=treeHolesService.list(content);
        return Result.success(list);
    }

    @GetMapping("/add")
    public Result add(String content){
        treeHolesService.add(content);
        return Result.success();
    }

    @GetMapping("/getAllComment/{id}")
    public Result<List<TreeHolesComment>> getAllComment(@PathVariable Long id){
        List<TreeHolesComment> treeHolesComments=treeHolesService.getAllComment(id);
        return Result.success(treeHolesComments);
    }
}
